<?php

namespace app\helper;

class Helper
{
    const SUCCESS_CODE = 200;

    const ERROR_CODE = 400;

    /**
     * 请求成功返回
     * @param array $data
     * @param null $msg
     * @param int $code
     * @return \think\response\Json
     */
    public static function success($data = [],$msg = null,$code = self::SUCCESS_CODE)
    {
        return json(['data'=>$data,'msg'=>$msg,'code'=>$code]);
    }

    /**
     * 错误返回
     * @param array $data
     * @param null $msg
     * @param int $code
     * @return \think\response\Json
     */
    public static function error($data = [],$msg = null,$code = self::ERROR_CODE)
    {
        return json(['data'=>$data,'msg'=>$msg,'code'=>$code]);
    }


}